<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
	<link rel="stylesheet" href="../../static/home/css/swiper-bundle.min.css">
    <script src="../../static/home/js/swiper-bundle.min.js"></script>
    <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <style>
        body,html{
            height: 100%;
            width: 100%;
            margin: 0px;
        }
        body {
            height: 100%;
            overflow:hidden;
            /* overflow: hidden;
            background-repeat: no-repeat;

            background-color: #1539AF;
            background-image: radial-gradient(#1539AF, #0b0b80);background-size: 100%; */
        }

        .main {
            position: absolute;
            width: 100vw;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
        }

        .ct {
            position: absolute;
            top: 65%;
            left: 50%;
            width: 100%;
            height: 100%;
            transform: translate(-50%, -50%);
            transform-style: preserve-3d;
            perspective-origin: center 30vh;
            perspective: 1000px;
            overflow: hidden;
        }
        .ct .item {
            font-size: 0;
            position: absolute;
            transform-origin: center;
            width: 400px;
            transform: translateZ(-10000px);
            background-color: rgba(176, 44, 47, 0.2);
            border: 8px solid #fff;
            opacity: 0;
            /* opacity: 1; */
            transition: opacity .5s linear;
            cursor: pointer;
        }

        .ct .item img {
            font-size: 0;
            width: 100%;
            height: 100%;
        }

        .text1 {
            position: absolute;
            z-index: 99;
            top: 240px;
            left: -1920px;
        }

        .text2 {
            position: absolute;
            z-index: 99;
            top: 450px;
            left: -1920px;
        }

        .text3 {
            position: absolute;
            z-index: 99;
            top: 660px;
            left: -1920px;
        }

        .slide1 {
            animation: .8s slide forwards;
        }

        .slide2 {
            animation: 1s slide 1.2s forwards;
        }

        .slide3 {
            animation: 1.2s slide 2.4s forwards;
        }

        @keyframes slide {
            from {
                left: -1920px;
            }

            to {
                left: 86.5px
            }
        }

        .pic-wrapper {
            /* display: none; */
            opacity: 0;
            z-index: -1;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 1650px;
            height: 928px;
            background-color: #fff;
            border: 8px solid rgba(255,255,255,.2);
            box-shadow: 0 0 3px 3px rgba(255,255,255,.5);
            transition: opacity .1s linear;
        }
        .pic-wrapper .close {
            position: absolute;
            width: 45px; height: 45px; background: #fff url(./images/close-ico.png) no-repeat center; right: -25px; top: -25px; z-index: 10; border-radius: 20px; box-shadow: 0 0 5px 5px rgba(255,255,255,.5); cursor: pointer;
        }

        .swiper-container {
            width: 100%;
            height: 100%;
        }

        .swiper-button-prev {
            left: -100px;
        }

        .swiper-button-next {
            right: -100px;
        }

        .swiper-slide,
        .swiper-slide img {
            margin: 0 auto;
            height: 100%;
            overflow: hidden;
            text-align: center;
        }

        .swiper-slide {
            display: flex;
            justify-content: center;
        }
    </style>
</head>
<body>
    <h2 style="color: white;margin-top: 70px;text-shadow: 0px 2px 20px white;text-align: center;z-index: 999;position: relative;">活动展示</h2>
    <div class="main">
        <div class="text">
             <img class="text text1 slide1" data-src="../../static/home/img/activity/1.jpg" alt="">
            <img class="text text2 slide2" data-src="../../static/home/img/activity/1.jpg" alt="">
            <img class="text text3 slide3" data-src="../../static/home/img/activity/1.jpg" alt=""> 
        </div>
        <div class="ct">

        </div>
        <div class="pic-wrapper">
            <div class="close"></div>
            <div class="swiper-container">
                <div class="swiper-wrapper">
                    <div class="swiper-slide">Slide 1</div>
                    <div class="swiper-slide">Slide 2</div>
                    <div class="swiper-slide">Slide 3</div>
                </div>
            </div>
            <div class="swiper-button-prev swiper-button-white"></div>
            <div class="swiper-button-next swiper-button-white"></div>
        </div>
    </div>

	

    
		<script>
			// (function() {
			let swiperNode = '';
			for (let i = 1, len = 10; i < len; i++) {
				swiperNode += '<div class="swiper-slide"><img data-src="../../static/home/img/activity/' + i + '.jpg" alt=""></div>'
			}
			$('.swiper-wrapper').html(swiperNode)

			let swiper = new Swiper('.swiper-container', {
				direction: 'horizontal', // 垂直切换选项
				loop: true, // 循环模式选项
				speed: 2,
			})

			setTimeout(function() {
				$('.text').animate({
					opacity: 0
				})
				$('.ct').show()
				move()
			}, 0)
			let htm = '';
			let timer

			for (let i = 1, len = 43; i < len; i++) {
				htm += '<div class="item" style="overflow:hidden;" i="' + i + '"><img src="../../static/home/img/activity/' + i + '.jpg" alt=""></div>'
			}
			$('.ct').html(htm)
			let list = $('.item')
            
			$('.ct').on('click', '.item', function() {
				// console.log(Number($(this).index()) + 1)
				// swiper.slideTo(Number($(this).index()) + 1)
				// // $('.pic-wrapper').show()
				// $('.pic-wrapper').css({
				// 	'opacity': 1,
				// 	'z-index': 99
				// })
				// $('.ct').hide()
			})

			$('.swiper-button-prev').on('click', function() {
				console.log('prev')
				swiper.slidePrev()
			})

			$('.swiper-button-next').on('click', function() {
				console.log('next')
				swiper.slideNext()
			})

			$('.close').on('click', function() {
				$('.ct').show()
				// $('.pic-wrapper').hide()
				$('.pic-wrapper').css({
					'opacity': 0,
					'z-index': -1
				})
			})

			function move() {
				for (let i = 0, len = list.length; i < len; i++) {
					if (i % 4 == 0) {
						$('.item').eq(i).css('top', -Number(Math.floor(Math.random() * 1000) + 200) + 'px');
						$('.item').eq(i).css('left', -Number(Math.floor(Math.random() * 2000) - 100) + 'px');
					} else if (i % 4 == 1) {
						$('.item').eq(i).css('top', -Number(Math.floor(Math.random() * 1000) + 200) + 'px');
						$('.item').eq(i).css('left', Number(Math.floor(Math.random() * 2000) - 100) + 'px');
					} else if (i % 4 == 2) {
						$('.item').eq(i).css('top', Number(Math.floor(Math.random() * 1000) + 200) + 'px');
						$('.item').eq(i).css('left', -Number(Math.floor(Math.random() * 2000) - 100) + 'px');
					} else {
						$('.item').eq(i).css('top', Number(Math.floor(Math.random() * 1000) + 200) + 'px');
						$('.item').eq(i).css('left', Number(Math.floor(Math.random() * 2000) - 100) + 'px');
					}
					$('.item').eq(i).attr('data-z', -10000)
					let delay = Math.floor(Math.random() * 10000)
					setTimeout(function() {
						let Z = ~~$('.item').eq(i).attr('data-z');
						timer = setInterval(function() {
							if (Z >= -9909) {
								$('.item').eq(i).css('opacity', 1)
							}
							if (Z >= -100) {
								$('.item').eq(i).css('opacity', 0)
							}
							if (Z >= 1000) {
								Z = -10000
							}
							$('.item').eq(i).css('transform', 'translateZ(' + Z + 'px)')
							Z += 10
						}, 5);
					}, delay)
				}
			}
            // 懒加载
           
            
           
		</script>
        <script>
            //此处引用：鼠标滚轮mousewheel插件
        !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});
            
            $(function(){
                var i=4;
                var $btn = parent.$('.section-btn li'),
                    $wrap = parent.$('.section-wrap'),
                    $arrow = parent.$('.arrow');
                
                /*当前页面赋值*/
                function up(){
                    i = 5;
                    console.log(i);
                }
                function down(){
                    i = 3;
                    
                    console.log(i);
                }
                
                /*页面滑动*/
                function run(){
                    console.log("run");
                    $btn.eq(i).addClass('on').siblings().removeClass('on');	
                    $wrap.attr("class","section-wrap").addClass(function() { return "put-section-"+i; }).find('.section').eq(i).find('.title').addClass('active');
                };
                
                /*右侧按钮点击*/
                $btn.each(function(index) {
                    $(this).click(function(){
                        i=index;
                        run();
                    })
                });
                
            //     /*翻页按钮点击*/
            //     $arrow.one('click',go);
            //     function go(){
            //         console.log('点击向下翻页啊啊啊')
			// console.log(i)
            //         // up();run();	
            //         // setTimeout(function(){$arrow.one('click',go)},1000)
            //     };
                
                $(document).bind('mousewheel DOMMouseScroll', function(event) {
                        // IE/Chorme
                        var wheel = event.originalEvent.wheelDelta;
                        // Firefox
                        var detal = event.originalEvent.detail;
                        // 判断浏览器IE,谷歌滚轮事件
                        if(event.originalEvent.wheelDelta) {
                            // 当滑轮向上滚动时
                            if(wheel > 0) {
                                console.log("up");
                                up()
                            }
                            // 当滑轮向下滚动时
                            if(wheel < 0) {
                                console.log("down");
                                down()
                            }
                            
                            setTimeout(function(){
                                run();
                            },1000)
                        }
                        // Firefox滚轮事件  
                        else if(event.originalEvent.detail) {
                            // 当滑轮向下滚动时
                            if(detal > 0) {
                                console.log("down");
                                down()
                            }
                            // 当滑轮向上滚动时
                            if(detal < 0) {
                                console.log("up");
                                up()
                            }
                            setTimeout(function(){
                                run();
                            },1000)
                        }
                    });
                /*响应键盘上下键*/
                $(document).one('keydown',k);
                function k(event){
                    var e=event||window.event;
                    var key=e.keyCode||e.which||e.charCode;
                    switch(key)	{
                        case 38: down();run();	
                        break;
                        case 40: up();run();	
                        break;
                    };
                    setTimeout(function(){$(document).one('keydown',k)},1000);
                }
                // 监听触摸屏
            let box = document.querySelector('body') // 监听对象
                let startTime = '' // 触摸开始时间
                let startDistanceX = '' // 触摸开始X轴位置
                let startDistanceY = '' // 触摸开始Y轴位置
                let endTime = '' // 触摸结束时间
                let endDistanceX = '' // 触摸结束X轴位置
                let endDistanceY = '' // 触摸结束Y轴位置
                let moveTime = '' // 触摸时间
                let moveDistanceX = '' // 触摸移动X轴距离
                let moveDistanceY = '' // 触摸移动Y轴距离
                box.addEventListener("touchstart", (e) => {
                    startTime = new Date().getTime()
                    startDistanceX = e.touches[0].screenX
                    startDistanceY = e.touches[0].screenY
                    console.log("开始")
                })
                box.addEventListener("touchend", (e) => {
                    endTime = new Date().getTime()
                    endDistanceX = e.changedTouches[0].screenX
                    endDistanceY = e.changedTouches[0].screenY
                    moveTime = endTime - startTime
                    moveDistanceX = startDistanceX - endDistanceX
                    moveDistanceY = startDistanceY - endDistanceY
                    console.log(moveDistanceX, moveDistanceY)
                //     target = e.target || e.srcElement;
                //     if(target.getAttribute('class') === "arrow"){
				// if(Math.abs(moveDistanceX) < 2 && Math.abs(moveDistanceY) < 2){
				// 	up()
				// 	run()
				// }
			// }
                    // 判断滑动距离超过40 且 时间小于500毫秒
                    if ((Math.abs(moveDistanceX) > 40 || Math.abs(moveDistanceY) > 40) && moveTime < 500) {
                        // 判断X轴移动的距离是否大于Y轴移动的距离
                        if (Math.abs(moveDistanceX) > Math.abs(moveDistanceY)) {
                        // 左右
                        console.log(moveDistanceX > 0 ? '左' : '右')
                        } else {
                        // 上下
                        console.log(moveDistanceY > 0 ? '上' : '下')
                            if(moveDistanceY>0){
                                up();
                            }else{
                                down();
                            }
                            run();
                        }
                    }
                    console.log("结束")
                })
            });
        </script>
</body>
</html>
